import com.fj.api.impl.StudentServiceImpl
import com.fj.pojo.Student
import com.fj.util.StringUtil

fun main() {
//    println("Hello World!")
//    testBasic()
//    println(testSelectBiggerNumber(3,8))
//    println(compareValue(1,1))
//    println(testForIn(5))
//    testClass()
//    testInterface()
//    testList()
//    testSet()
//    testMap()
//    testThread()
    testCallJava()
}

fun testBasic() {
    println("abc")

}

fun testSelectBiggerNumber(a:Int,b:Int):Int = if (a > b) a else b

/**
 * ==类似于equals
 * ===类似于=，比较指针
 */
fun compareValue(a:Any,b:Any):Boolean {
    return a == b
}

fun testForIn(a:Int){
//    for (i in 0..a){
//        print(i)
//        println()
//    }
//    for (i in 0 until a){
//        println(i)
//    }
//    for (i in 0 until 10 step 2){
//        println(i)
//    }
    for (i in 10 downTo 0 step 2){
        println(i)
    }
}

fun testClass(){
//    val person = Person()
//    person.name = "张三"
//    person.age = 33
//    person.printInfo()
//    var student = Student()
//    student.name = "小明"
//    student.age = 9
//    student.number = "8971283712"
//    student.printInfo()
//    student.readBook("语文")
    val student = Student("小明", 9, "8971283712")
    student.printInfo()
    student.readBook("语文")
}

fun testInterface(){
    val studentServiceImpl = StudentServiceImpl()
    studentServiceImpl.sayHello("张三")
}

fun testList(){
    var arrayList = ArrayList<Any>()
    arrayList.add("m")
    arrayList.add("a")
    arrayList.add("c")
    for (v in arrayList){
        println(v)
    }
}

fun testSet(){
    var set = HashSet<Any>()
    set.add("m")
    set.add("a")
    set.add("c")
    for (v in set){
        println(v)
    }
}

fun testMap(){
    val hashMap = HashMap<Any, Any>()
    hashMap.set("a","aa")
    hashMap.set("b","bb")
    hashMap.set("c","cc")
    for (v in hashMap){
        println(v)
    }
    for ((k,v) in hashMap){
        println(k)
        println(v)
    }
}

fun testThread(){
    for (i in 0 until 5 step 1){
        Thread(object : Runnable{
            override fun run() {
                val tn = Thread.currentThread().name
                println("$tn run!")
            }

        }).start()
    }
}

fun testCallJava(){
    println(StringUtil.toUpperCase("abc"))
}